package view;

import java.awt.Color;
import java.awt.Font;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.WindowConstants;

import controller.CustomerController;
import controller.EmloyeeController;
import controller.InvoiceController;
import controller.ProductController;

public class Home extends JFrame {
	private static final long serialVersionUID = 1L;
	private JButton btnEmployee, btnCustomer, btnProduct, btnInvoice,
			btnStatistic, btnLogout;
	private JPanel pnHome, pnMenu;
	private JSeparator jSeparator1;
	private JToolBar toolbarMenu;
	private MenuCustomerPanel cus;
	private JLabel lblName;

	private JPanel pnMenuCurrent, pnHomeCurrent;

	private MenuCustomerPanel pnMenuCus;
	private MenuEmployeePanel pnMenuEmp;
	private MenuInvoicePanel pnMenuInvo;
	private MenuProductsPanel pnMenuPro;
	private MenuStatisticPanel pnMenuSta;

	private CusAddPanel pnCusAdd;
	private CusViewPanel pnCusView;

	private EmViewPanel pnEmpView;
	private EmAddPanel pnEmpAdd;
	private EmChangePassPanel pnEmpChange;

	private ProAddPanel pnProAdd;
	private ProAddSupPanel pnProAddSup;
	private ProViewPanel pnProView;
	private ProViewSupPanel pnProViewSup;

	private InvoiceAddPanel pnInvoiceAdd;
	private InVoiceViewPanel pnInvoiceView;

	public Home() {
		initComponents();
		pnMenuCurrent = new MenuCustomerPanel(this);
		pnHomeCurrent = new CusViewPanel();

		pnMenu.setLayout(null);
		pnMenu.add(pnMenuCurrent);
		pnMenuCurrent.setBounds(0, 0, 218, 353);

		pnHome.add(pnHomeCurrent);
		pnHomeCurrent.setBounds(0, 0, pnHome.getWidth(), pnHome.getHeight());

		setTitle("Home");
		setSize(950, 554);
		setResizable(false);
		controller();

	}

	private void newCom() {
		pnMenuCus = new MenuCustomerPanel(this);
		pnMenuEmp = new MenuEmployeePanel(this);
		pnMenuInvo = new MenuInvoicePanel(this);
		pnMenuSta = new MenuStatisticPanel(this);
		pnMenuPro = new MenuProductsPanel(this);

		pnMenuCurrent = new JPanel();
		pnHomeCurrent = new JPanel();

		pnCusAdd = new CusAddPanel();
		pnCusView = new CusViewPanel();

		pnEmpAdd = new EmAddPanel();
		pnEmpChange = new EmChangePassPanel();
		pnEmpView = new EmViewPanel();

		pnProAdd = new ProAddPanel();
		pnProAddSup = new ProAddSupPanel();
		pnProView = new ProViewPanel();
		pnProViewSup = new ProViewSupPanel();

		pnInvoiceAdd = new InvoiceAddPanel();
		pnInvoiceView = new InVoiceViewPanel();
	}

	public JButton getBtnEmployee() {
		return btnEmployee;
	}

	public void setBtnEmployee(JButton btnEmployee) {
		this.btnEmployee = btnEmployee;
	}

	public JButton getBtnCustomer() {
		return btnCustomer;
	}

	public void setBtnCustomer(JButton btnCustomer) {
		this.btnCustomer = btnCustomer;
	}

	public JButton getBtnProduct() {
		return btnProduct;
	}

	public void setBtnProduct(JButton btnProduct) {
		this.btnProduct = btnProduct;
	}

	public JButton getBtnInvoice() {
		return btnInvoice;
	}

	public void setBtnInvoice(JButton btnInvoice) {
		this.btnInvoice = btnInvoice;
	}

	public JButton getBtnStatistic() {
		return btnStatistic;
	}

	public void setBtnStatistic(JButton btnStatistic) {
		this.btnStatistic = btnStatistic;
	}

	public JButton getBtnLogout() {
		return btnLogout;
	}

	public void setBtnLogout(JButton btnLogout) {
		this.btnLogout = btnLogout;
	}

	public JPanel getpnHome() {
		return pnHome;
	}

	public void setpnHome(JPanel pnHome) {
		this.pnHome = pnHome;
	}

	public JSeparator getjSeparator1() {
		return jSeparator1;
	}

	public void setjSeparator1(JSeparator jSeparator1) {
		this.jSeparator1 = jSeparator1;
	}

	public JToolBar getToolbarMenu() {
		return toolbarMenu;
	}

	public void setToolbarMenu(JToolBar toolbarMenu) {
		this.toolbarMenu = toolbarMenu;
	}

	public JPanel getpnMenu() {
		return pnMenu;
	}

	public void setpnMenu(JPanel pnMenu) {
		this.pnMenu = pnMenu;
	}

	public MenuCustomerPanel getCus() {
		return cus;
	}

	public void setCus(MenuCustomerPanel cus) {
		this.cus = cus;
	}

	public MenuCustomerPanel getPnMenuCus() {
		return pnMenuCus;
	}

	public void setPnMenuCus(MenuCustomerPanel pnMenuCus) {
		this.pnMenuCus = pnMenuCus;
	}

	public MenuEmployeePanel getPnMenuEmp() {
		return pnMenuEmp;
	}

	public void setPnMenuEmp(MenuEmployeePanel pnMenuEmp) {
		this.pnMenuEmp = pnMenuEmp;
	}

	public MenuInvoicePanel getPnMenuInvo() {
		return pnMenuInvo;
	}

	public void setPnMenuInvo(MenuInvoicePanel pnMenuInvo) {
		this.pnMenuInvo = pnMenuInvo;
	}

	public MenuProductsPanel getPnMenuPro() {
		return pnMenuPro;
	}

	public void setPnMenuPro(MenuProductsPanel pnMenuPro) {
		this.pnMenuPro = pnMenuPro;
	}

	public MenuStatisticPanel getPnMenuSta() {
		return pnMenuSta;
	}

	public void setPnMenuSta(MenuStatisticPanel pnMenuSta) {
		this.pnMenuSta = pnMenuSta;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public JPanel getPnMenuCurrent() {
		return pnMenuCurrent;
	}

	public void setPnMenuCurrent(JPanel pnMenuCurrent) {
		this.pnMenuCurrent = pnMenuCurrent;
	}

	public JPanel getPnHome() {
		return pnHome;
	}

	public void setPnHome(JPanel pnHome) {
		this.pnHome = pnHome;
	}

	public JPanel getPnMenu() {
		return pnMenu;
	}

	public void setPnMenu(JPanel pnMenu) {
		this.pnMenu = pnMenu;
	}

	public JPanel getPnHomeCurrent() {
		return pnHomeCurrent;
	}

	public void setPnHomeCurrent(JPanel pnHomeCurrent) {
		this.pnHomeCurrent = pnHomeCurrent;
	}

	public CusAddPanel getPnCusAdd() {
		return pnCusAdd;
	}

	public void setPnCusAdd(CusAddPanel pnCusAdd) {
		this.pnCusAdd = pnCusAdd;
	}

	public CusViewPanel getPnCusView() {
		return pnCusView;
	}

	public void setPnCusView(CusViewPanel pnCusView) {
		this.pnCusView = pnCusView;
	}

	public EmViewPanel getPnEmpView() {
		return pnEmpView;
	}

	public void setPnEmpView(EmViewPanel pnEmpView) {
		this.pnEmpView = pnEmpView;
	}

	public EmAddPanel getPnEmpAdd() {
		return pnEmpAdd;
	}

	public void setPnEmpAdd(EmAddPanel pnEmpAdd) {
		this.pnEmpAdd = pnEmpAdd;
	}

	public EmChangePassPanel getPnEmpChange() {
		return pnEmpChange;
	}

	public void setPnEmpChange(EmChangePassPanel pnEmpChange) {
		this.pnEmpChange = pnEmpChange;
	}

	public ProAddPanel getPnProAdd() {
		return pnProAdd;
	}

	public void setPnProAdd(ProAddPanel pnProAdd) {
		this.pnProAdd = pnProAdd;
	}

	public ProAddSupPanel getPnProAddSup() {
		return pnProAddSup;
	}

	public void setPnProAddSup(ProAddSupPanel pnProAddSup) {
		this.pnProAddSup = pnProAddSup;
	}

	public ProViewPanel getPnProView() {
		return pnProView;
	}

	public void setPnProView(ProViewPanel pnProView) {
		this.pnProView = pnProView;
	}

	public ProViewSupPanel getPnProViewSup() {
		return pnProViewSup;
	}

	public void setPnProViewSup(ProViewSupPanel pnProViewSup) {
		this.pnProViewSup = pnProViewSup;
	}

	public InvoiceAddPanel getPnInvoiceAdd() {
		return pnInvoiceAdd;
	}

	public void setPnInvoiceAdd(InvoiceAddPanel pnInvoiceAdd) {
		this.pnInvoiceAdd = pnInvoiceAdd;
	}

	public InVoiceViewPanel getPnInvoiceView() {
		return pnInvoiceView;
	}

	public void setPnInvoiceView(InVoiceViewPanel pnInvoiceView) {
		this.pnInvoiceView = pnInvoiceView;
	}

	private void controller() {
		btnEmployee.addActionListener(new EmloyeeController(this));
		btnCustomer.addActionListener(new CustomerController(this));
		btnProduct.addActionListener(new ProductController(this));
		btnInvoice.addActionListener(new InvoiceController(this));

	}

	private void initComponents() {
		newCom();
		lblName = new JLabel("Hi! Admin");
		toolbarMenu = new JToolBar();
		btnEmployee = new JButton();
		btnCustomer = new JButton();
		btnProduct = new JButton();
		btnInvoice = new JButton();
		btnStatistic = new JButton();
		btnLogout = new JButton();
		pnMenu = new JPanel();
		pnHome = new JPanel();
		jSeparator1 = new JSeparator();

		setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		setBackground(new java.awt.Color(255, 255, 255));
		getContentPane().setLayout(null);

		toolbarMenu.setFloatable(false);
		toolbarMenu.setFocusable(false);
		toolbarMenu.setRequestFocusEnabled(false);
		toolbarMenu.setVerifyInputWhenFocusTarget(false);

		lblName.setBounds(800, 5, 200, 50);
		lblName.setBackground(Color.red);
		lblName.setFont(new Font("Arial", 1, 20));
		getContentPane().add(lblName);

		btnEmployee.setFont(new java.awt.Font("Calibri", 1, 18));
		btnEmployee.setIcon(new ImageIcon("icon/employee.png"));
		btnEmployee.setText("Employee");
		btnEmployee.setFocusable(false);
		btnEmployee.setHorizontalTextPosition(SwingConstants.RIGHT);
		btnEmployee.setIconTextGap(-5);
		toolbarMenu.add(btnEmployee);

		btnCustomer.setFont(new java.awt.Font("Calibri", 1, 18));
		btnCustomer.setIcon(new ImageIcon("icon/customers.png"));
		btnCustomer.setText("Customer");
		btnCustomer.setFocusable(false);
		btnCustomer.setHorizontalTextPosition(SwingConstants.RIGHT);
		btnCustomer.setPreferredSize(new java.awt.Dimension(140, 55));
		btnCustomer.setVerifyInputWhenFocusTarget(false);
		toolbarMenu.add(btnCustomer);

		btnProduct.setFont(new java.awt.Font("Calibri", 1, 18));
		btnProduct.setIcon(new ImageIcon("icon/products.png"));
		btnProduct.setText("Products");
		btnProduct.setFocusable(false);
		btnProduct.setHorizontalTextPosition(SwingConstants.RIGHT);
		toolbarMenu.add(btnProduct);

		btnInvoice.setFont(new java.awt.Font("Calibri", 1, 18));
		btnInvoice.setIcon(new ImageIcon("icon/invoice.png"));
		btnInvoice.setText("Invoice");
		btnInvoice.setFocusable(false);
		btnInvoice.setHorizontalTextPosition(SwingConstants.RIGHT);
		toolbarMenu.add(btnInvoice);

		btnStatistic.setFont(new java.awt.Font("Calibri", 1, 18));
		btnStatistic.setIcon(new ImageIcon("icon/chart-icon.png"));
		btnStatistic.setText("Statistic");
		btnStatistic.setFocusable(false);
		btnStatistic.setHorizontalTextPosition(SwingConstants.RIGHT);
		btnStatistic.setPreferredSize(new java.awt.Dimension(120, 55));
		toolbarMenu.add(btnStatistic);

		btnLogout.setFont(new java.awt.Font("Calibri", 1, 18));
		btnLogout.setIcon(new ImageIcon("icon/logout2.png"));
		btnLogout.setText("Logout");
		btnLogout.setFocusable(false);
		btnLogout.setHorizontalTextPosition(SwingConstants.RIGHT);
		toolbarMenu.add(btnLogout);

		getContentPane().add(toolbarMenu);
		toolbarMenu.setBounds(0, 0, 880, 57);

		pnMenu.setBackground(new java.awt.Color(255, 255, 255));
		pnMenu.setLayout(null);
		getContentPane().add(pnMenu);
		pnMenu.setBounds(0, 70, 230, 440);

		pnHome.setBackground(new java.awt.Color(255, 255, 255));
		pnHome.setLayout(null);
		getContentPane().add(pnHome);
		pnHome.setBounds(240, 70, 750, 440);

		getContentPane().add(jSeparator1);
		jSeparator1.setBounds(0, 62, 1000, 10);

		pack();
	}

	public static void main(String args[]) {
		try {
			for (UIManager.LookAndFeelInfo info : UIManager
					.getInstalledLookAndFeels()) {
				if ("Windows".equals(info.getName())) {
					UIManager.setLookAndFeel(info.getClassName());
					break;
				}
			}
		} catch (ClassNotFoundException ex) {
			java.util.logging.Logger.getLogger(Home.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		} catch (InstantiationException ex) {
			java.util.logging.Logger.getLogger(Home.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		} catch (IllegalAccessException ex) {
			java.util.logging.Logger.getLogger(Home.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		} catch (UnsupportedLookAndFeelException ex) {
			java.util.logging.Logger.getLogger(Home.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		}
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				new Home().setVisible(true);
			}
		});
	}

}
